namespace CubicFWNet.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class init : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.ItemCategory",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        CreatorId = c.Guid(),
                        SortNo = c.Int(nullable: false),
                        Memo = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.Name, unique: true, name: "IX_Name_ItemCategory");
            
            CreateTable(
                "dbo.Item",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CategoryId = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        CreatorId = c.Guid(nullable: false),
                        SortNo = c.Int(nullable: false),
                        Memo = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.CategoryId, name: "IX_CategoryId_Item")
                .Index(t => t.Name, unique: true, name: "IX_Name_Item");
            
            CreateTable(
                "dbo.LogInLog",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Time = c.DateTime(nullable: false),
                        UserId = c.Guid(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 50),
                        FamilyName = c.String(maxLength: 50),
                        Type = c.String(nullable: false, maxLength: 50),
                        IPAddress = c.String(maxLength: 50, unicode: false),
                        IPAddressName = c.String(maxLength: 100, unicode: false),
                        Memo = c.String(maxLength: 200),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.Time, name: "IX_Time_LogInLog")
                .Index(t => new { t.Time, t.FamilyName }, name: "IX_Time-FamilyName_LogInLog");
            
            CreateTable(
                "dbo.Module",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CascadeId = c.String(maxLength: 50),
                        Name = c.String(nullable: false, maxLength: 50),
                        Url = c.String(maxLength: 256),
                        IsLeaf = c.Boolean(nullable: false),
                        IconName = c.String(maxLength: 256, unicode: false),
                        Status = c.Boolean(nullable: false),
                        SortNo = c.Int(nullable: false),
                        ParentId = c.Guid(),
                        ParentName = c.String(maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        CreatorId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.ParentId, name: "IX_ParentId_Module");
            
            CreateTable(
                "dbo.OperatorLog",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserId = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        Description = c.String(maxLength: 1024),
                        ModuleUrl = c.String(maxLength: 128, unicode: false),
                        Status = c.String(maxLength: 16, unicode: false),
                        EmOpeartor = c.Int(nullable: false),
                        Time = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Relevance",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Description = c.String(maxLength: 100),
                        Type = c.String(maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        CreatorId = c.Guid(nullable: false),
                        FirstId = c.Guid(nullable: false),
                        SecondId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => new { t.FirstId, t.Type }, unique: true, name: "IX_FirstId-Type_Relevance");
            
            CreateTable(
                "dbo.Role",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        CreatorId = c.Guid(nullable: false),
                        SortNo = c.Int(nullable: false),
                        Memo = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.Name, unique: true, name: "IX_Name_Role");
            
            CreateTable(
                "dbo.User",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 50),
                        Password = c.String(nullable: false, maxLength: 128, unicode: false),
                        FamilyName = c.String(nullable: false, maxLength: 50),
                        Status = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        CreatorId = c.Guid(nullable: false),
                        SortNo = c.Int(nullable: false),
                        Memo = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => t.UserName, unique: true, name: "IX_UserName_User")
                .Index(t => t.FamilyName, name: "IX_FamilyName_User");
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.User", "IX_FamilyName_User");
            DropIndex("dbo.User", "IX_UserName_User");
            DropIndex("dbo.Role", "IX_Name_Role");
            DropIndex("dbo.Relevance", "IX_FirstId-Type_Relevance");
            DropIndex("dbo.Module", "IX_ParentId_Module");
            DropIndex("dbo.LogInLog", "IX_Time-FamilyName_LogInLog");
            DropIndex("dbo.LogInLog", "IX_Time_LogInLog");
            DropIndex("dbo.Item", "IX_Name_Item");
            DropIndex("dbo.Item", "IX_CategoryId_Item");
            DropIndex("dbo.ItemCategory", "IX_Name_ItemCategory");
            DropTable("dbo.User");
            DropTable("dbo.Role");
            DropTable("dbo.Relevance");
            DropTable("dbo.OperatorLog");
            DropTable("dbo.Module");
            DropTable("dbo.LogInLog");
            DropTable("dbo.Item");
            DropTable("dbo.ItemCategory");
        }
    }
}
